<script setup>
    import { ref } from 'vue'
    import { useRouter } from 'vue-router';
    import request from '../../request/axios'

    const router = useRouter();

    // 获取收藏list数据
    const collectList = ref([])
    const getCollectList = async () => {
        try {
            const data = {}
            data.page = 1
            data.pageNum = 12
            const res = await request.getV2({ url: '/v1/api-collect-list', data })
            collectList.value = res.data.list
        } catch (error) {
            console.log(error)
        }
    }
    getCollectList()

    const clickDel = async (item) => {
        let data = {
            id: item.id
        }
        const res = await request.postV2({ url: '/v1/api-collect-del', data })
        if (res.code == 200) {
            getCollectList()
        }

    }

</script>

<template>
    <div class="content-collection overflow-none">
        <div class="collection-title">收藏对话</div>
        <div class="card-list">
            <div class="card-item" v-for="item in collectList" :key="item"
                @click="router.push('/share?type=2&id=' + item.id)">
                <div class="card-title nowrap-hide">{{item.title || '--'}}</div>
                <div class="card-message nowrap-hide-4">{{item.content || '--'}}</div>
                <div class="card-bottom">
                    <div class="card-time">
                        {{item.create_time}} 对话
                    </div>
                    <div class="card-icon">
                        <!--  @click="router.push('/chatBot')" -->
                        <!-- <img src="../../assets/image/icon/login-chat.png" /> -->
                        <img @click.stop="clickDel(item)" src="../../assets/image/icon/collection-del.png" />
                    </div>
                </div>
            </div>
        </div>
        <el-empty :image-size="200" description="暂无收藏对话" v-if="collectList.length === 0" />
    </div>
</template>

<style scoped lang="scss">
    .content-collection {
        max-width: 1200px;
        width: 80%;
        overflow: hidden;
        overflow-y: auto;
        padding: 50px 20px;
        margin: 0 auto;

        .collection-title {
            font-size: 20px;
            font-weight: bold;
            color: #000000;
            padding-left: 20px;
            margin-bottom: 18px;
        }

        .card-list {
            display: flex;
            flex-wrap: wrap;
            /* align-items: center;
            justify-content: start; */

            .card-item {
                width: calc(100% / 3 - 50px);
                padding: 11px;
                margin: 0 14px 20px;
                border-radius: 8px;
                background: #FFFFFF;
                box-shadow: 0px 0px 7px 0px rgba(0, 0, 0, 0.08);

                .card-title {
                    font-size: 16px;
                    font-weight: bold;
                    color: #000000;
                }

                .card-message {
                    font-size: 14px;
                    line-height: 25px;
                    height: 100px;
                    margin: 10px 0;
                    color: rgba(0, 0, 0, 0.7);
                }

                .card-bottom {
                    display: flex;
                    align-items: center;
                    justify-content: space-between;
                    font-size: 13px;
                    color: rgba(153, 153, 153, 0.7);

                    .card-icon {
                        display: flex;
                        align-items: center;

                        img {
                            cursor: pointer;
                            margin-left: 10px;
                        }
                    }
                }
            }
        }
    }
</style>